﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Default/Shared/SiteForSystem.Master"
    Inherits="System.Web.Mvc.ViewPage<K.ClientOfMVC.Models.AccountModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="NoRightContent" runat="server">
    <script type="text/javascript" src="/Library/Scripts/area.js"></script>
    <%
        K.ClientOfMVC.Models.MainModel mainModel = (K.ClientOfMVC.Models.MainModel)ViewData["MainModel"];
        if (mainModel.appInfo.IsCloseRegister)
        {
    %>
            <div class="error"><%=mainModel.appInfo.Error%>></div>
    <%   }%>
    <!--正常注册部分开始-->
    <div class="register">
        <div class="clearpix">
        </div>
        <h3>用户注册<%=ViewData.Model.errors %></h3>
        <%using (Html.BeginForm()) {%>
        <div class="pitem" style="margin-top: 25px;">
            <em>用户名：</em>
            <%=Html.TextBox("username", "", new { @class="f-text", id="username", maxlength="20", onblur="javascript:checkusername();",
                onkeyup="value=value.replace(/[^\\w\\.\\_/]/ig,'')",  style="width: 150px;"})%>
            <span class="errors" id="spanusername" style="display: none;"></span><span class="rights"
                id="spanusername1" style="display: none;"></span>
        </div>
        <div class="pitem">
            <em>密码：</em>
            <%=Html.Password("password", "", new { id="password" ,maxlength="18", onblur="javascript:checkpassword()",
            @class="f-text", style="width: 150px;"})%>
            <span class="errors" id="spanpassword" style="display: none;"></span><span class="rights"
                id="spanpassword1" style="display: none;"></span>
        </div>
        <div class="pitem">
            <em>确认密码：</em>
            <%=Html.Password("confimpassword", "", new { id="confimpassword", onblur="javascript:checkconfimpassword()",
            maxlength="18",  @class="f-text", style="width: 150px;"})%>
            <span class="errors" id="spanconfimpassword" style="display: none;"></span><span
                class="rights" id="spanconfimpassword1" style="display: none;"></span>
        </div>
        <div style="border-bottom: 1px solid #eeeeee; padding: 5px; margin-bottom: 10px;">
        </div>
                <div class="pitem">
            <em>电子邮件</em>
            <%=Html.TextBox("email","",new{id="email", maxlength="100" ,
            onblur="javascript:checkemail()" ,onkeyup="value=value.replace(/[^\\w\\.\\_\\-\\@/]/ig,'')",
            @class="f-text", style="width: 150px;"} )%>
            <span class="errors" id="spanemail" style="display: none;"></span><span class="rights"
                id="spanemail1" style="display: none;"></span>
        </div>
        <%if (ViewData.Model.isVCode == 1)
          {%>
        <div class="pitem">
            <em>请填写答案：</em><img src="/Page/Verifycode" style="width: 75px;
                height: 25px" id="vimgs" align="absmiddle" />
            <%=Html.TextBox("text", "", new
                {
                    id = "vcode",
                    onblur = "javascript:checkvcode()",
                    maxlength = "5",
                    @class = "f-text",
                    style = "width: 40px;"
                })%>
            <span class="rights" id="spanvcode1" style="display: none;"></span>&nbsp; <a href="javascript:void(0)"
                onclick="document.getElementById('vimgs').src='/Page/verifycode?v='+Math.random()+''">
                看不清，换一张</a> <span class="errors" id="spanvcode" style="display: none;"></span>
        </div>
        <%} %>
        <div class="pitem">
            <em>&nbsp;</em><a href="/Help/info.cs?q=regcontent" target="_blank">点击查看《服务条款》</a></div>
        <div class="pitem1">
            <em>&nbsp;</em>
            <input type="submit" name="button1" id="SubmitSend" class="btn_blue6" onclick="return checkdata();"
                value="同意条款并注册" />
            <input type="reset" name="button1" class="btn_gray4" value="重新填写" />
            <input id="inviteid" name="inviteid" type="hidden" value="$inviteid" />
            <input id="replayEmail" name="replayEmail" type="hidden" value="$replayEmail" />
            <a href="/Account/Result">Result</a>
        </div>
        <%} %>
    </div>
    <script type="text/javascript">
        function ChangeProv(obj) {
            var objcity = document.getElementById('SlctCity');
            objcity.style.display = '';
            objcity.options.length = 0;
            for (i = 0; i < Area.length; i++) {
                if (Area[i][0] == obj.value) {
                    var opt = document.createElement('option');
                    opt.value = Area[i][1];
                    opt.innerHTML = Area[i][2];
                    objcity.appendChild(opt);
                }
            }
        }

        function changevcode() {
            document.getElementById("vimgs").src = "$webpath/library/page/verifycode${exname}?v=" + Math.random() + ""
        }
        function checkusername() {
            var err = "";
            jQuery("#spanusername1").hide();
            var username = jQuery("#username").val();
            if (username == "") {
                err += "填写用户名\n";
            }
            else {
                if (!/^[a-zA-Z0-9_\.]{3,18}$/.test(username)) {
                    err += "用户名由3-18个英文、数字、下划线及点组成。不能包含特殊字符和中文。";
                }
            }
            if (err != "") {
                jQuery("#spanusername").show();
                jQuery("#spanusername").html(err);
                return false;
            }
            else {
                jQuery("#spanusername").hide();
                return CheckUserExsitAjax(username, 0);
                //return true;
            }
        }
        function checkemail() {
            var err = "";
            var email = jQuery("#email").val();
            if (email == "") {
                err += "填写电子邮件";
            }
            else {
                if (isEmail(email)) {
                    err += "电子邮件格式不正确";
                }
            }
            if (err != "") {
                jQuery("#spanemail1").hide();
                jQuery("#spanemail").show();
                jQuery("#spanemail").html(err);
                return false;
            }
            else {
                jQuery("#spanemail").hide();
                return CheckUserExsitAjax(email, 1);
            }
        }
        function checkpassword() {
            var err = "";
            var password = jQuery("#password").val();
            if (password.length < 3 || password.length > 18) {
                err += "密码长度必须大于3个字符小于18个字符";
            }
            if (err != "") {
                jQuery("#spanpassword").show();
                jQuery("#spanpassword1").hide();
                jQuery("#spanpassword").html(err);
                return false;
            }
            else {
                jQuery("#spanpassword1").show();
                jQuery("#spanpassword").hide();
                return true;
            }
        }
        function checkconfimpassword(obj) {
            var err = "";
            var confimpassword = jQuery("#confimpassword").val();
            if (confimpassword != jQuery("#password").val()) {
                err += "两次密码不一致";
            }
            if (err != "") {
                jQuery("#spanconfimpassword").show();
                jQuery("#spanconfimpassword1").hide();
                jQuery("#spanconfimpassword").html(err);
                return false;
            }
            else {
                jQuery("#spanconfimpassword1").show();
                jQuery("#spanconfimpassword").hide();
                return true;
            }
        }

        function checktruename() {
            try {
                var err = "";
                var truename = jQuery("#truename").val();
                if (truename == "" || truename.length < 2) {
                    err += "填写真实姓名，真实姓名必须2个字符以上\n";
                }
                var patrns = /^(\w|[\u4E00-\u9FA5])*$/;
                if (/[^\u4E00-\u9FA5a-zA-Z]/.test(truename)) {
                    err += "姓名只能是中文或英文\n";
                }
                if (err != "") {
                    jQuery("#spantruename").show();
                    jQuery("#spantruename1").hide();
                    jQuery("#spantruename").html(err);
                    return false;
                }
                else {
                    jQuery("#spantruename1").show();
                    jQuery("#spantruename").hide();
                    return true;
                }
            }
            catch (e) {
                return true;
            }
        }
        function checkvcode() {
            try {
                var err = "";
                var vcode = jQuery("#vcode").val();
                if (vcode == "") {
                    err += "填写验证码\n";
                }
                if (err != "") {
                    jQuery("#spanvcode").show();
                    jQuery("#spanvcode1").hide();
                    jQuery("#spanvcode").html(err);
                    return false;
                }
                else {
                    jQuery("#spanvcode1").show();
                    jQuery("#spanvcode").hide();
                    return true;
                }
            }
            catch (e) {
                return true;
            }
        }
        function birthday() {
            var err = "";
            if (jQuery("#birthdayYear").val() == "" || jQuery("#birthdayMonth").val() == "" || jQuery("#birthdayDay").val() == "") {
                err += "请填写生日，填写后可以可设置是否显示。";
            }
            if (err != "") {
                jQuery("#spanbirthday").show();
                jQuery("#spanbirthday1").hide();
                jQuery("#spanbirthday").html(err);
                return false;
            }
            else {
                jQuery("#spanbirthday1").show();
                jQuery("#spanbirthday").hide();
                return true;
            }
        }

        function checkdata() {
            if (checkusername() == false) { jQuery("#username").focus(); return false; }
            if (checkemail() == false) { jQuery("#email").focus(); return false; }
            if (!checkpassword()) { jQuery("#password").focus(); return false; }
            if (!checkconfimpassword()) { jQuery("#confimpassword").focus(); return false; }
            if (!checktruename()) { jQuery("#truename").focus(); return false; }
            if (!birthday()) { jQuery("#birthdayYear").focus(); return false; }
            if (!checkvcode()) { return false; }
            if (document.getElementById("SlctProvince").options[document.getElementById("SlctProvince").selectedIndex].text == "") {
                jQuery("#spancity").show();
                jQuery("#spancity").html("请选择省份");
                jQuery("#SlctProvince").focus();
                return false;
            }
            return true;
        }


    </script>
</asp:Content>
